package com.commerceE.util;
/**
 *=====================================================================
 * String 
 *
 *---------------------------------------------------------------------
 * Update date  Contents
 *=====================================================================
 * 08/02/2011   create
 *
 */	 

public final class StringUtils {
  

  /**
   * Test for null/empty and no whitespace string.
   * @param string
   * @return true if string is null or blank
   */
  public static boolean isBlank(String string) {
    return (string == null || string.trim().length() == 0);
  }

  /**
   * Test for not null string.
   * @param string
   * @return true if string is not null or blank
   */
  public static boolean isNotBlank(String aString) {
	boolean isBlank = false;
	
	if ( aString != null ) {
	   isBlank = aString.trim().length() != 0;
	} 
	return isBlank;
  }

  /**
   * Checks if a string contains a boolean true.
   * Currently the strings "true", "yes", and "1" are considered true.
   * All other strings (including null) are considered false.
   */
  public static boolean isTrue(String str) {
    return ( (str != null)
             && (str.equalsIgnoreCase("true")
             || str.equalsIgnoreCase("yes")
             || str.equals("1")
          ));
  }

  /**
   * Test for Integer in string.
   * @param string
   * @return true if string is Int.
   */
  public static boolean isNumber(String value) {
    try {
    	if (value.contains(".")) {
    		Float.parseFloat(value);
    	} else {
    		Integer.parseInt(value);
    	}
        return true;
    } catch (NumberFormatException ex) {
      return false;
    }
  }
    
}

